/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package reamodel.provider;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

import reamodel.util.ReamodelAdapterFactory;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class ReamodelItemProviderAdapterFactory extends ReamodelAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ReamodelItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.REAModel} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected REAModelItemProvider reaModelItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.REAModel}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createREAModelAdapter() {
		if (reaModelItemProvider == null) {
			reaModelItemProvider = new REAModelItemProvider(this);
		}

		return reaModelItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.EconomicResourceType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EconomicResourceTypeItemProvider economicResourceTypeItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.EconomicResourceType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEconomicResourceTypeAdapter() {
		if (economicResourceTypeItemProvider == null) {
			economicResourceTypeItemProvider = new EconomicResourceTypeItemProvider(this);
		}

		return economicResourceTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.EconomicAgentType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EconomicAgentTypeItemProvider economicAgentTypeItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.EconomicAgentType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEconomicAgentTypeAdapter() {
		if (economicAgentTypeItemProvider == null) {
			economicAgentTypeItemProvider = new EconomicAgentTypeItemProvider(this);
		}

		return economicAgentTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.IncrementEconomicEventType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IncrementEconomicEventTypeItemProvider incrementEconomicEventTypeItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.IncrementEconomicEventType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createIncrementEconomicEventTypeAdapter() {
		if (incrementEconomicEventTypeItemProvider == null) {
			incrementEconomicEventTypeItemProvider = new IncrementEconomicEventTypeItemProvider(this);
		}

		return incrementEconomicEventTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.DecrementEconomicEventType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DecrementEconomicEventTypeItemProvider decrementEconomicEventTypeItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.DecrementEconomicEventType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createDecrementEconomicEventTypeAdapter() {
		if (decrementEconomicEventTypeItemProvider == null) {
			decrementEconomicEventTypeItemProvider = new DecrementEconomicEventTypeItemProvider(this);
		}

		return decrementEconomicEventTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.EconomicResource} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EconomicResourceItemProvider economicResourceItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.EconomicResource}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEconomicResourceAdapter() {
		if (economicResourceItemProvider == null) {
			economicResourceItemProvider = new EconomicResourceItemProvider(this);
		}

		return economicResourceItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.EconomicAgent} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EconomicAgentItemProvider economicAgentItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.EconomicAgent}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createEconomicAgentAdapter() {
		if (economicAgentItemProvider == null) {
			economicAgentItemProvider = new EconomicAgentItemProvider(this);
		}

		return economicAgentItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.IncrementEconomicEvent} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IncrementEconomicEventItemProvider incrementEconomicEventItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.IncrementEconomicEvent}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createIncrementEconomicEventAdapter() {
		if (incrementEconomicEventItemProvider == null) {
			incrementEconomicEventItemProvider = new IncrementEconomicEventItemProvider(this);
		}

		return incrementEconomicEventItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.DecrementEconomicEvent} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DecrementEconomicEventItemProvider decrementEconomicEventItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.DecrementEconomicEvent}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createDecrementEconomicEventAdapter() {
		if (decrementEconomicEventItemProvider == null) {
			decrementEconomicEventItemProvider = new DecrementEconomicEventItemProvider(this);
		}

		return decrementEconomicEventItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.IncrementCommitment} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IncrementCommitmentItemProvider incrementCommitmentItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.IncrementCommitment}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createIncrementCommitmentAdapter() {
		if (incrementCommitmentItemProvider == null) {
			incrementCommitmentItemProvider = new IncrementCommitmentItemProvider(this);
		}

		return incrementCommitmentItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.DecrementCommitment} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DecrementCommitmentItemProvider decrementCommitmentItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.DecrementCommitment}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createDecrementCommitmentAdapter() {
		if (decrementCommitmentItemProvider == null) {
			decrementCommitmentItemProvider = new DecrementCommitmentItemProvider(this);
		}

		return decrementCommitmentItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.ReceiveParticipation} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ReceiveParticipationItemProvider receiveParticipationItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.ReceiveParticipation}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createReceiveParticipationAdapter() {
		if (receiveParticipationItemProvider == null) {
			receiveParticipationItemProvider = new ReceiveParticipationItemProvider(this);
		}

		return receiveParticipationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.ProvideParticipation} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProvideParticipationItemProvider provideParticipationItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.ProvideParticipation}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createProvideParticipationAdapter() {
		if (provideParticipationItemProvider == null) {
			provideParticipationItemProvider = new ProvideParticipationItemProvider(this);
		}

		return provideParticipationItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.Inflow} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InflowItemProvider inflowItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.Inflow}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInflowAdapter() {
		if (inflowItemProvider == null) {
			inflowItemProvider = new InflowItemProvider(this);
		}

		return inflowItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.Outflow} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected OutflowItemProvider outflowItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.Outflow}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createOutflowAdapter() {
		if (outflowItemProvider == null) {
			outflowItemProvider = new OutflowItemProvider(this);
		}

		return outflowItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.InflowType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InflowTypeItemProvider inflowTypeItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.InflowType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInflowTypeAdapter() {
		if (inflowTypeItemProvider == null) {
			inflowTypeItemProvider = new InflowTypeItemProvider(this);
		}

		return inflowTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link reamodel.OutflowType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected OutflowTypeItemProvider outflowTypeItemProvider;

	/**
	 * This creates an adapter for a {@link reamodel.OutflowType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createOutflowTypeAdapter() {
		if (outflowTypeItemProvider == null) {
			outflowTypeItemProvider = new OutflowTypeItemProvider(this);
		}

		return outflowTypeItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (reaModelItemProvider != null) reaModelItemProvider.dispose();
		if (economicResourceTypeItemProvider != null) economicResourceTypeItemProvider.dispose();
		if (economicAgentTypeItemProvider != null) economicAgentTypeItemProvider.dispose();
		if (incrementEconomicEventTypeItemProvider != null) incrementEconomicEventTypeItemProvider.dispose();
		if (decrementEconomicEventTypeItemProvider != null) decrementEconomicEventTypeItemProvider.dispose();
		if (economicResourceItemProvider != null) economicResourceItemProvider.dispose();
		if (economicAgentItemProvider != null) economicAgentItemProvider.dispose();
		if (incrementEconomicEventItemProvider != null) incrementEconomicEventItemProvider.dispose();
		if (decrementEconomicEventItemProvider != null) decrementEconomicEventItemProvider.dispose();
		if (incrementCommitmentItemProvider != null) incrementCommitmentItemProvider.dispose();
		if (decrementCommitmentItemProvider != null) decrementCommitmentItemProvider.dispose();
		if (receiveParticipationItemProvider != null) receiveParticipationItemProvider.dispose();
		if (provideParticipationItemProvider != null) provideParticipationItemProvider.dispose();
		if (inflowItemProvider != null) inflowItemProvider.dispose();
		if (outflowItemProvider != null) outflowItemProvider.dispose();
		if (inflowTypeItemProvider != null) inflowTypeItemProvider.dispose();
		if (outflowTypeItemProvider != null) outflowTypeItemProvider.dispose();
	}

}
